﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Win.BLL;
using Win.Model;
using static ShiYan3.Login;

namespace ShiYan3
{
    public partial class NewMainForm : Form
    {
        public NewMainForm()
        {
            InitializeComponent();
        }

        private void MenuItem_quit_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void NewMainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            Application.Exit();
        }

        private void NewMainForm_Load(object sender, EventArgs e)
        {
            if (Mtype == "0")
            {
                MenuItem_user.Visible = false;
            }
            InitListView();
        }
        private void MenuItem_user_Click(object sender, EventArgs e)
        {
            new ManegerForm().Show();
        }

        private void MenuItem_dish_Click(object sender, EventArgs e)
        {
            new DishForm().Show();
        }

        private void MenuItem_table_Click(object sender, EventArgs e)
        {
            new Table().Show();
        }

        private void InitListView()
        {
            listView1.LargeImageList = imageList1;
            listView1.MultiSelect = false;
            listView1.Items.Clear();
            TableBLL tableInfoBll = new TableBLL();
            List<TableInfo> tableInfoList = tableInfoBll.GetTables();
            foreach (TableInfo tableInfo in tableInfoList)
            {
                //通过构造函数，用指定的item文本和item图标的图像索引位置进行初始化 
                ListViewItem item = new ListViewItem(tableInfo.TTitle,
                    tableInfo.TIsFree.Equals("否") ? 1 : 0);
                item.Tag = tableInfo.TId;
                listView1.Items.Add(item);
            }
        }

    }
}
